﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using GCELibrary.Current;
 
using System.Linq.Dynamic;
 
using System.Xml.Linq;
using System.Data;
using ZF.BLL;

namespace GCEVideoMonitor.Manage
{

    public partial class Left : ZF.BLL.Page.MMPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindMenu();
        }

        protected void BindMenu()
        {
 
            
            
            
            XDocument xml = XDocument.Load(Server.MapPath(string.Format("~/{0}/sitemenu.xml",AppKey.SiteKey.ManageDirectory)));
            var source = from menu in xml.Element("menu").Elements("submenu")
                         select new
                         {
                             M = menu,
                             L = menu.Elements().Where(lk => CheckModule(lk.Attribute("right").Value) == true),
                             COUNT = menu.Elements().Where(lk => CheckModule(lk.Attribute("right").Value) == true).Count()
                         };
            lvMenu.DataSource = source;
            lvMenu.DataBind();
           
        }

        protected bool CheckModule(string module)
        {
            return CurrentUser.RightModules.Contains(module);



            return true;

            //bool resualt = ModuleRightConfig.CheckModuleRight(CurrentUser, module.Convert<ModuleType>("站点文件配置错误"));
            //return resualt;
        }

        protected virtual void AlertTimeOut()
        {
      
           throw this.WarnFactory.CreateWarn(WarnCode.LoginTimeOut);
        }

        //protected override void CheckChangePwd()
        //{
        //    //base.CheckChangePwd();
        //}
    }
     
}
